package com.example.jdimust.account;

/**
 * Author: MaZongyang
 * Date: 2021/5/19/0019 15:42
 * Description:数据账本适配器
 */
import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.example.jdimust.R;

import java.util.List;

public class AccountAdapter extends ArrayAdapter<Account> {
    private int resourceId;

    public AccountAdapter(Context context, int textViewResourceId, List<Account> objects) {

        super(context, textViewResourceId, objects);
        resourceId = textViewResourceId;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        Account account = getItem(position);
        @SuppressLint("ViewHolder")
        View view = LayoutInflater.from(getContext()).inflate(resourceId, parent, false);
        TextView accname = (TextView) view.findViewById(R.id.acc_lv_accname);
        TextView acccrtime = (TextView) view.findViewById(R.id.acc_lv_crttime);
        TextView accid = (TextView) view.findViewById(R.id.acc_lv_id);
        TextView accsta = (TextView) view.findViewById(R.id.acc_lv_sta);
        TextView acchash = (TextView) view.findViewById(R.id.acc_lv_acchash);
        accname.setText(account.getAccountName());
        acccrtime.setText(account.getAccountCreateTime());
        accid.setText(account.getId());
        accsta.setText(account.getState());
        acchash.setText(account.getAccountHash());
        return view;

    }
}
